package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo11 {
    public static void main(String[] args) {


        try(Connection connection = DBUtil.getConnection();) {
            connection.setAutoCommit(false);//设置是否自动提交
            String sql = "DELETE FROM userinfo WHERE id = 3";
            PreparedStatement ps = connection.prepareStatement(sql);
            int i = ps.executeUpdate();
            System.out.println(i>0?"删除成功":"删除失败");
//        connection.commit();提交
            connection.rollback();//回滚
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
